package com.museum.generator;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;

import java.util.Collections;

/** MP代码生成器
 * @author Akihi
 * @create 2022/12/09
 */
public class CodeGenerator {
    public static void main(String[] args) {
        FastAutoGenerator.create("jdbc:mysql://127.0.0.1:3306/hakka?useSSL=false&useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true",
                        "root", "root")
                .globalConfig(builder -> {
                    builder.author("Akihi") // 设置作者
                            //.enableSwagger() // 开启 swagger 模式
                            .fileOverride()  // 覆盖已生成文件
                            .outputDir("E:\\Courses\\Work\\MuseumProject\\museum-admin-java\\src\\main\\java"); // 指定输出目录
                })
                .packageConfig(builder -> {
                    builder.parent("com.museum") // 设置父包名
                            //.moduleName("vueadmin") // 设置父包模块名
                            .pathInfo(Collections.singletonMap(OutputFile.xml,
                                    "E:\\Courses\\Work\\MuseumProject\\museum-admin-java\\src\\main\\resources\\mapper")); // 设置mapperXml生成路径
                })
                .strategyConfig(builder -> {   //策略配置
                    builder.addInclude("admin_user","mandarin_to_hakka", "single_word", "user", "user_answers", "wordentry"); // 设置需要生成的表名, 多个表名用,隔开
                })
                .templateEngine(new FreemarkerTemplateEngine())
                /*
                模板引擎配置，默认 Velocity 可选模板引擎 Beetl 或 Freemarker 或 Enjoy
               .templateEngine(new VelocityTemplateEngine())
               .templateEngine(new BeetlTemplateEngine())
               .templateEngine(new FreemarkerTemplateEngine())
               .templateEngine(new EnjoyTemplateEngine())
             */
                .execute();
    }

}
